package net.tv90.bfmccoreqqbot.api.handler;

import net.tv90.bfmccore.api.info.PlayerStatistic;
import net.tv90.bfmccoreqqbot.api.MessageHandler;
import net.tv90.bfmccoreqqbot.api.annotation.MessageCheck;
import net.tv90.bfmccoreqqbot.api.annotation.MessageCheckPolicy;
import net.tv90.bfmccoreqqbot.api.annotation.MessageType;
import net.tv90.bfmccoreqqbot.api.entity.MessageContext;

@MessageType("玩家信息")
@MessageCheck(MessageCheckPolicy.STARTS_WITH)
public class PlayerStatsMessageHandler implements MessageHandler {

    @Override
    public String handleMessage(MessageContext msg) {

        String[] args = msg.getMessage().split(" ");
        if (args.length == 2) {
            String playerName = args[1];
            System.out.println(PlayerStatistic.getPlayerStatistic(playerName));
            return PlayerStatistic.getPlayerStatistic(playerName);
        }

        return "格式有误，格式: 玩家信息 <玩家名>";
    }

    @Override
    public boolean onPreHandleMessage(MessageContext msg) {
        System.out.println("接受到消息: " + msg.getMessage());
        return true;
    }
}
